import { makeAutoObservable } from 'mobx'
import { http, getToken, setToken, delToken } from '@/utils'
import { login } from '@/api'
class LoginStore {
  token = getToken() || ''
  constructor() {
    makeAutoObservable(this)
  }
  // 登录
  login = async ({ mobile, code }) => {
    const res = await login({ mobile, code })
    this.token = res.data.token
    // 存入token  
    setToken(this.token)
  }
  loginOut = () => {
    this.token = ''
    delToken()
  }
}
export default LoginStore